<%@ page language="java" %>
<%@ page import="java.util.List, java.util.Iterator,
ro.gateway.aida.search.ResultsFormat"%>


<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> 
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/translator.tld" prefix="trans" %>

<script type="text/javascript" src="<html:rewrite page='/javascript/picklist.js'/>"></script>
<script type="text/javascript" src="<html:rewrite page='/javascript/utils.js'/>"></script>
<script type="text/javascript">
	function submitForm()
	{
	strValue=eval("document.theform.name.value");
	strValue=trim(strValue);
	if(strValue=="")
	    {
	    alert("Please type in a name for the format!");
	    return false;
	    }
	return selIt();
	}
</script>
<trans:initPage module="search2" />

<%ResultsFormat resformat=(ResultsFormat)request.getAttribute("resformat");
	String mode="update";
	if(resformat.getId()==0) mode="save";	 
%>


<form NAME="theform" ID="theform" METHOD="POST" ACTION="<html:rewrite page='/resultsFormat.do'/>" onSubmit="return submitForm();">
<input type="hidden" name="id" value="<%=resformat.getId()%>" />
<input type="hidden" name="mode" value="<%=mode%>" />
<table>
<tr>
<td>
	Format name : <input type="text" name="name" value='<bean:write name="resformat" property="name"/>' />
	
</td>
</tr>
<tr>

<td>
<select NAME="SelectList" ID="SelectList" SIZE="5" class="text" multiple="multiple" style="width: 200px ; height: 150px">
	<%List l=ResultsFormat.getDefinedColumns();
	Iterator i=l.iterator();
	while(i.hasNext()) {
	String c=(String)i.next();
	%>
	<option VALUE="<%=c%>">
	<trans:showPageMessage hide_link="true">
			<%=c%>
	</trans:showPageMessage>
	</option>
	<%}%>
</select>



</td>
<td>
<input TYPE="BUTTON" class="buton" VALUE="->" ONCLICK="addIt();"></input>
<br>
<input TYPE="BUTTON" class="buton" VALUE="<-" ONCLICK="delIt();"></input>
</td>
<td>
<select class="text" NAME="PickList" ID="PickList" SIZE="5" multiple="multiple" style="width: 200px ; height: 150px">
<%
resformat.initTokenizer();
	while(true) {
		String key=resformat.getNextColumn();
		if(key==null) break;
		%><option VALUE="<%=key%>">
		<trans:showPageMessage hide_link="true">
			<%=key%>
		</trans:showPageMessage>
		</option>
<%}%>
</select>
</td>
</tr>
<tr>

<td>

</td>
<td ALIGN="right" >
<input TYPE="submit" VALUE="Submit" class="butonsave"/>
</td>
</tr>
</table>
<div class="text">
<b><trans:showPageMessage label="describe_the_process"/></b>
</div>

</form>




